package com.chuanyang.driverh.mainorder.adapter;


import android.content.Context;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.TextView;

import com.chuanyang.driverh.R;
import com.chuanyang.driverh.responseresult.ShipperMsgData;

import java.util.ArrayList;

/**
 * 常运路线
 * Created by eason on 2016/7/26.
 */
public class OffenTranslateLinesAdapter extends BaseAdapter {
    private ArrayList list;
    private Context context;



    public void setList(ArrayList list) {
        this.list = list;
        notifyDataSetChanged();
    }

    public OffenTranslateLinesAdapter(ArrayList list, Context context){
        this.list=list;
        this.context=context;
    }
    @Override
    public int getCount() {
        return  list.size();
    }

    @Override
    public Object getItem(int position) {
        return null;
    }

    @Override
    public long getItemId(int position) {
        return 0;
    }

    @Override
    public View getView(int position, View convertView, ViewGroup parent) {
        if(convertView==null)
        {
            convertView= View.inflate(context, R.layout.order_item_offentranslateline,null);

        }
        ViewHolder holder= ViewHolder.getHolder(convertView);
        ShipperMsgData.ShipperLinesBean bean= (ShipperMsgData.ShipperLinesBean) list.get(position);
        holder.linesort.setText("专线"+position+"：");
        holder.beginpalace.setText(bean.getSPoint());
        holder.arrivepalace.setText(bean.getEPoint());
        return convertView;
    }

    public static  class ViewHolder
    {
        private TextView linesort,beginpalace,arrivepalace;
          public ViewHolder(View convertView)
          {
               beginpalace= (TextView) convertView.findViewById(R.id.tv_offenline_beginpalace);
               arrivepalace= (TextView) convertView.findViewById(R.id.tv_offenline_arrivepalace);
               linesort= (TextView) convertView.findViewById(R.id.tv_offenline_linesort);

          }

        public static ViewHolder getHolder(View convertView) {
            ViewHolder holder= (ViewHolder) convertView.getTag();
            if(holder==null)
            {
                holder=new ViewHolder(convertView);
                convertView.setTag(holder);
            }
            return  holder;
        }
    }




}
